//
//  FirmwareResetViewModel.swift
//  DaRings
//
//  Created by 魔样科技 on 2022/12/5.
//

import Foundation
import CRPSmartRing
import RxSwift
import RxCocoa

open class FirmwareResetViewModel: NSObject {
    
    public let items = BehaviorRelay<Bool>(value: false)
    
    public override init() {
        super.init()

        BluetoothManager.shared.reset()
        
        NotificationCenter.default.rx.notification(Notification.Name.kDeviceStateNotification).subscribe(onNext:{ [weak self] notification in
            guard let self = self else { return }
            guard let result = notification.userInfo as? [String: Any] else { return}
            guard let state = result["result"] as? CRPState else { return }
            switch state{
            case .connected:
                self.items.accept(true)
            default:
                break
            }
            
          

        }).disposed(by: rx.disposeBag)

    }
}
